using DealerPlatform.Domain;
using DealerPlatform.Service.CustomerApp.Dtos;
using DealerPlatform.Service.OrderApp.Dtos;

namespace DealerPlatform.Service.CustomerApp;

public partial class CustomerService
{
    private async Task SaleOrderDtoLocalEventHandler(SaleOrderDto saleOrderDto)
    {
        saleOrderDto.CustomerInvoice = await GetCustomerInvoiceAsync(saleOrderDto.InvoiceNo);
    }
    
    public async Task<List<InvoiceOfOrderConfirmDto>> GetInvoiceByUser(string customerNo)
    {
        var invoice = await customerInvoiceRepository.GetListAsync(m=>m.CustomerNo==customerNo);
        return mapper.Map<List<CustomerInvoice>, List<InvoiceOfOrderConfirmDto>>(invoice);
    }

    private async Task<CustomerInvoice> GetCustomerInvoiceAsync(string invoiceNo)
    {
        return await customerInvoiceRepository.GetAsync(m => m.InvoiceNo == invoiceNo);
    }
}